﻿@page
@{
    ViewData["Title"] = "Excel导入";
    Layout = "~/Pages/Admin/_Layout.cshtml";
}

<div id="app">
    <div class="layui-upload-drag" id="file">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处</p>
       
    </div>


    <div class="layui-input-block" style="margin-left:330px;margin-top:30px;">
        <button type="button" class="layui-btn" id="upload">开始上传</button>
    </div>

</div>

<script>
    layui.use(['upload','common'], function () {
        var $ = layui.$, os = layui.common,
            upload = layui.upload;

          //选完文件后不自动上传
          upload.render({
             elem: '#file'
            ,url: '/api/admin/sysuser/ImportExcel' 
            ,auto: false        
            ,bindAction: '#upload'
            ,accept: 'file' //普通文件
            ,exts: 'xls|xlsx' //只允许上传excel文件
              , done: function (res) {

                  if (res.code == 1) {

                      layer.msg(res.msg, { time: 1000 }, function () {
                          os.closeOpen();
                      });
                      //刷新父页面的数据
                      $('button[data-type="reload"]', window.parent.document).click();
                  } else {
                      layer.msg(res.msg);
                  }
              }
              , error: function () {
                  //请求异常回调
              }
          });
    });
   
</script>

